<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>商品税号编辑</title>
    <jsp:include page="../../head.jsp"/>
    <script type="text/javascript" src="<s:url value="/js/layer/layer.js"/>"></script>
    <script type="text/javascript">
        var formSetting = {
            title: "新增与修改",
            module: 'save',
            numCount: 1,
            columns: [
                {
                    name: "gName",
                    label: "商品名",
                    value: "${goodsCode.gName}"
                }, {
                    name: "codeT",
                    label: "商品编码",
                    value: "${goodsCode.codeT}",
                    validate: 'validate[required]'
                }, {
                    name: "codeS",
                    label: "商品编码附加码",
                    value: "${goodsCode.codeS}",
                    validate: 'validate[required]'
                }, {
                    name: "unit1",
                    label: "法定单位",
                    value: "${goodsCode.unit1}",
                    validate: 'validate[required]',
                }, {
                    name: "unit2",
                    label: "第二单位",
                    value: "${goodsCode.unit2}"
                }, {
                    name: "goodsMode",
                    label: "商品要素",
                    value: "${goodsCode.goodsMode}"
                }],
            buttons: {
                custom: []
            },

            form: {
                'url': 'saveGoodsCode',
                'ajaxForm': {
                    beforeSubmit: function () {
                        var codeT = "${goodsCodeKey.codeT}";
                        var codeS = "${goodsCodeKey.codeS}";
                        var valid = false;
                        $.ajax({
                            type: 'post',
                            url: "/goods/deleteGoods",
                            dataType: 'json',
                            data: {"codeT":codeT,"codeS":codeS},
                            async: false,
                            success: function (data) {
                                valid = data;
                            }
                        });
                        return valid;
                    },
                    success: function (data) {
                        if (data.result) {
                            layer.alert(data.msg, {
                                title: false,
                                anim: 0
                            }, function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                        } else {
                            layer.alert(data.msg, {
                                title: false,
                                anim: 0
                            });
                        }
                        return false;
                    }
                }
            }
        };
        $(document).ready(function () {
            $("#table").mrdForm(formSetting);
        });
    </script>
</head>
<body>
<div id="table"></div>
</body>
</html>
